package com.game.miniprogram;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;

/**
 * 牛马薪资计算器
 */

public class SalaryCalculator extends JFrame {
    private JTextField workDaysField, monthlySalaryField, startTimeField, endTimeField;
    private static final Color PRIMARY_COLOR = new Color(243, 227, 228);     // 主色调：粉色
    private static final Color ACCENT_COLOR = new Color(119, 80, 27);     // 强调色：紫色
    private static final Color SECONDARY_COLOR = new Color(231, 76, 60);   // 辅助色：红色
    private static final Color SUCCESS_COLOR = new Color(46, 204, 113);    // 成功色：绿色
    private static final Color WARNING_COLOR = new Color(243, 156, 18);    // 警告色：橙色
    private static final Color LIGHT_COLOR = new Color(248, 250, 252);     // 浅色背景
    private static final Color DARK_COLOR = new Color(44, 62, 80);         // 深色文本

    private static final Color HIGHLIGHT_COLOR = new Color(204, 229, 205); // 高亮背景色

    // 用于存储用户第一次输入的值
    private static String savedWorkDays = null;
    private static String savedMonthlySalary = null;
    private static String savedStartTime = null;
    private static String savedEndTime = null;

    // 窗口移动相关变量
    private static Point initialClick;
    private JFrame currentFrame;

    public SalaryCalculator() {
        setTitle("牛马薪资计算器");
        setSize(300, 410);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
        setUndecorated(true);
        getRootPane().setWindowDecorationStyle(JRootPane.QUESTION_DIALOG);
        setResizable(false); // 设置窗口不可调整大小
        setAlwaysOnTop(true);// 设置窗口钉在桌面
        currentFrame = this;

        initComponents();
        makeFrameDraggable();
    }

    private void initComponents() {
        // 使用自定义边框实现阴影效果
        JPanel mainPanel = new ShadowPanel();
        mainPanel.setLayout(new BorderLayout());
        mainPanel.setBackground(LIGHT_COLOR);

        // 顶部标题栏 - 使用渐变背景
        JPanel titlePanel = new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                Graphics2D g2d = (Graphics2D) g;
                g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
                GradientPaint gp = new GradientPaint(
                        0, 0, PRIMARY_COLOR,
                        getWidth(), 0, PRIMARY_COLOR);
                g2d.setPaint(gp);
                g2d.fillRect(0, 0, getWidth(), getHeight());
            }
        };
        titlePanel.setLayout(new FlowLayout(FlowLayout.CENTER, 10, 15));
        titlePanel.setPreferredSize(new Dimension(0, 60));

        JLabel titleLabel = new JLabel("牛马薪资计算器");
        titleLabel.setFont(new Font("微软雅黑", Font.BOLD, 18));
        titleLabel.setForeground(ACCENT_COLOR);

        titlePanel.add(titleLabel);
        mainPanel.add(titlePanel, BorderLayout.NORTH);

        // 输入面板 - 使用卡片式设计
        JPanel inputPanel = new JPanel(new GridBagLayout());
        inputPanel.setBackground(LIGHT_COLOR);
        inputPanel.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createEmptyBorder(15, 15, 15, 15),
                BorderFactory.createLineBorder(new Color(220, 220, 220), 1, true)
        ));

        GridBagConstraints gbc = new GridBagConstraints();
        gbc.insets = new Insets(8, 15, 8, 15);
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;

        JLabel workDaysLabel = createLabel("当月总天数:");
        JLabel monthlySalaryLabel = createLabel("月薪 (元):");
        JLabel startTimeLabel = createLabel("上班时间:");
        JLabel endTimeLabel = createLabel("下班时间:");

        // 使用保存的值或默认值
        workDaysField = createTextField(savedWorkDays != null ? savedWorkDays : getDaysInCurrentMonth());
        monthlySalaryField = createTextField(savedMonthlySalary != null ? savedMonthlySalary : "8000");
        startTimeField = createTextField(savedStartTime != null ? savedStartTime : "09:00");
        endTimeField = createTextField(savedEndTime != null ? savedEndTime : "18:00");

        // 使用圆角按钮并添加悬停效果
        JButton confirmButton = new JButton("开始计算") {
            @Override
            protected void paintComponent(Graphics g) {
                if (getModel().isPressed()) {
                    g.setColor(PRIMARY_COLOR.darker());
                } else if (getModel().isRollover()) {
                    g.setColor(PRIMARY_COLOR.brighter());
                } else {
                    g.setColor(PRIMARY_COLOR);
                }
                g.fillRoundRect(0, 0, getWidth(), getHeight(), 15, 15);
                super.paintComponent(g);
            }

            @Override
            public Dimension getPreferredSize() {
                return new Dimension(180, 40);
            }
        };

        confirmButton.setFont(new Font("微软雅黑", Font.BOLD, 14));
        confirmButton.setForeground(ACCENT_COLOR);
        confirmButton.setFocusPainted(false);
        confirmButton.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15));
        confirmButton.setContentAreaFilled(false);
        confirmButton.setOpaque(false);

        confirmButton.addActionListener(e -> {
            try {
                // 保存用户输入的值
                saveUserInput();

                int workDays = Integer.parseInt(workDaysField.getText());
                double monthlySalary = Double.parseDouble(monthlySalaryField.getText());
                LocalTime startTime = LocalTime.parse(startTimeField.getText(), DateTimeFormatter.ofPattern("HH:mm"));
                LocalTime endTime = LocalTime.parse(endTimeField.getText(), DateTimeFormatter.ofPattern("HH:mm"));

                dispose();
                new ResultFrame(workDays, monthlySalary, startTime, endTime, currentFrame.getBounds()).setVisible(true);
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(SalaryCalculator.this,
                        "输入格式错误，请检查！\n(示例: 天数=22, 月薪=8000, 时间=09:00)",
                        "输入错误", JOptionPane.ERROR_MESSAGE);
            }
        });

        // 关闭按钮
        JButton closeButton = new JButton("关闭") {
            @Override
            protected void paintComponent(Graphics g) {
                if (getModel().isPressed()) {
                    g.setColor(PRIMARY_COLOR.darker());
                } else if (getModel().isRollover()) {
                    g.setColor(PRIMARY_COLOR.brighter());
                } else {
                    g.setColor(PRIMARY_COLOR);
                }
                g.fillRoundRect(0, 0, getWidth(), getHeight(), 15, 15);
                super.paintComponent(g);
            }

            @Override
            public Dimension getPreferredSize() {
                return new Dimension(180, 40);
            }
        };

        closeButton.setFont(new Font("微软雅黑", Font.BOLD, 14));
        closeButton.setForeground(ACCENT_COLOR);
        closeButton.setFocusPainted(false);
        closeButton.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15));
        closeButton.setContentAreaFilled(false);
        closeButton.setOpaque(false);

        closeButton.addActionListener(e -> {
            dispose();
        });

        // 布局输入组件
        gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 0.3; inputPanel.add(workDaysLabel, gbc);
        gbc.gridx = 1; gbc.weightx = 0.7; inputPanel.add(workDaysField, gbc);
        gbc.gridx = 0; gbc.gridy = 1; inputPanel.add(monthlySalaryLabel, gbc);
        gbc.gridx = 1; inputPanel.add(monthlySalaryField, gbc);
        gbc.gridx = 0; gbc.gridy = 2; inputPanel.add(startTimeLabel, gbc);
        gbc.gridx = 1; inputPanel.add(startTimeField, gbc);
        gbc.gridx = 0; gbc.gridy = 3; inputPanel.add(endTimeLabel, gbc);
        gbc.gridx = 1; inputPanel.add(endTimeField, gbc);

        gbc.gridx = 0; gbc.gridy = 4; gbc.gridwidth = 1; gbc.anchor = GridBagConstraints.CENTER;
        gbc.fill = GridBagConstraints.NONE;
        inputPanel.add(confirmButton, gbc);

        gbc.gridx = 1; gbc.gridy = 4; gbc.gridwidth = 1; gbc.anchor = GridBagConstraints.CENTER;
        gbc.fill = GridBagConstraints.NONE;
        inputPanel.add(closeButton, gbc);

        mainPanel.add(wrapInPanel(inputPanel, 20, 20, 10, 20), BorderLayout.CENTER);

        // 底部面板
        JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
        bottomPanel.setBackground(PRIMARY_COLOR);
        bottomPanel.setPreferredSize(new Dimension(0, 30));

        JLabel infoLabel = new JLabel("© 2025 牛马薪资计算器 | 专业版 Author:663");
        infoLabel.setFont(new Font("微软雅黑", Font.PLAIN, 12));
        infoLabel.setForeground(Color.WHITE);
        bottomPanel.add(infoLabel);

        mainPanel.add(bottomPanel, BorderLayout.SOUTH);

        add(mainPanel);
    }

    private void saveUserInput() {
        savedWorkDays = workDaysField.getText();
        savedMonthlySalary = monthlySalaryField.getText();
        savedStartTime = startTimeField.getText();
        savedEndTime = endTimeField.getText();
    }

    private String getDaysInCurrentMonth() {
        int i = LocalDate.now().lengthOfMonth();
        return String.valueOf(i);
    }

    private JLabel createLabel(String text) {
        JLabel label = new JLabel(text);
        label.setFont(new Font("微软雅黑", Font.PLAIN, 14));
        label.setForeground(DARK_COLOR);
        return label;
    }

    private JTextField createTextField(String placeholder) {
        JTextField textField = new JTextField(placeholder) {
            @Override
            protected void paintComponent(Graphics g) {
                if (!hasFocus() && getText().isEmpty()) {
                    Graphics2D g2 = (Graphics2D) g.create();
                    g2.setColor(UIManager.getColor("TextField.inactiveForeground"));
                    g2.setFont(getFont());
                    g2.drawString(placeholder, getInsets().left, g.getFontMetrics().getMaxAscent() + getInsets().top);
                    g2.dispose();
                }
                super.paintComponent(g);
            }
        };

        textField.setFont(new Font("微软雅黑", Font.PLAIN, 14));
        textField.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createLineBorder(new Color(200, 200, 200), 1),
                BorderFactory.createEmptyBorder(8, 10, 8, 10)
        ));

        textField.setPreferredSize(new Dimension(200, 35));
        return textField;
    }

    private JPanel wrapInPanel(JComponent component, int top, int left, int bottom, int right) {
        JPanel wrapper = new JPanel(new BorderLayout());
        wrapper.setBackground(LIGHT_COLOR);
        wrapper.setBorder(BorderFactory.createEmptyBorder(top, left, bottom, right));
        wrapper.add(component, BorderLayout.CENTER);
        return wrapper;
    }

    // 使窗口可拖动
    private void makeFrameDraggable() {
        addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
                initialClick = e.getPoint();
                getComponentAt(initialClick);
            }
        });

        addMouseMotionListener(new MouseMotionAdapter() {
            @Override
            public void mouseDragged(MouseEvent e) {
                // 获取当前窗口位置
                int thisX = currentFrame.getLocation().x;
                int thisY = currentFrame.getLocation().y;

                // 计算移动距离
                int xMoved = e.getX() - initialClick.x;
                int yMoved = e.getY() - initialClick.y;

                // 移动窗口
                currentFrame.setLocation(thisX + xMoved, thisY + yMoved);
            }
        });
    }

    private static class ResultFrame extends JFrame {
        private JLabel currentDayEarningsLabel, monthEarningsLabel, remainingTimeLabel, currentTimeLabel;
        private Timer timer;
        private final double secondSalary;
        private final double dailySalary;
        private final LocalTime startTime, endTime;
        private LocalDate today;
        private Rectangle previousBounds;

        public ResultFrame(int workDays, double monthlySalary, LocalTime startTime, LocalTime endTime, Rectangle previousBounds) {
            this.startTime = startTime;
            this.endTime = endTime;
            this.today = LocalDate.now();
            this.previousBounds = previousBounds;

            dailySalary = monthlySalary / workDays;
            secondSalary = dailySalary / (endTime.toSecondOfDay() - startTime.toSecondOfDay());

            setTitle("薪资计算结果");
            setSize(260, 400);
            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            setLocationRelativeTo(null);
            setUndecorated(true);
            getRootPane().setWindowDecorationStyle(JRootPane.INFORMATION_DIALOG);
            setResizable(false); // 设置窗口不可调整大小
            setAlwaysOnTop(true);// 设置窗口钉在桌面

            initResultComponents();
            startTimer();
            makeFrameDraggable();
        }

        private void initResultComponents() {
            JPanel mainPanel = new ShadowPanel();
            mainPanel.setLayout(new BorderLayout());
            mainPanel.setBackground(LIGHT_COLOR);

            // 顶部标题栏
            JPanel titlePanel = new JPanel() {
                @Override
                protected void paintComponent(Graphics g) {
                    super.paintComponent(g);
                    Graphics2D g2d = (Graphics2D) g;
                    g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
                    GradientPaint gp = new GradientPaint(
                            0, 0, PRIMARY_COLOR,
                            getWidth(), 0, PRIMARY_COLOR);
                    g2d.setPaint(gp);
                    g2d.fillRect(0, 0, getWidth(), getHeight());
                }
            };

            titlePanel.setLayout(new FlowLayout(FlowLayout.CENTER, 10, 15));
            titlePanel.setPreferredSize(new Dimension(0, 60));

            JLabel titleLabel = new JLabel("薪资实时计算");
            titleLabel.setFont(new Font("微软雅黑", Font.BOLD, 22));
            titleLabel.setForeground(ACCENT_COLOR);

            titlePanel.add(titleLabel);
            mainPanel.add(titlePanel, BorderLayout.NORTH);

            // 结果显示面板 - 使用BoxLayout实现垂直居中
            JPanel resultPanel = new JPanel();
            resultPanel.setLayout(new BoxLayout(resultPanel, BoxLayout.Y_AXIS));
            resultPanel.setBackground(LIGHT_COLOR);
            resultPanel.setBorder(BorderFactory.createEmptyBorder(20, 40, 20, 40));
            resultPanel.setAlignmentY(Component.CENTER_ALIGNMENT);

            // 今日已赚 - 特殊样式
            JPanel todayPanel = createHighlightValuePanel("今日已赚", currentDayEarningsLabel = createResultLabel("¥0.00"), WARNING_COLOR);
            // 本月累计
            JPanel monthPanel = createHighlightValuePanel("本月累计", monthEarningsLabel = createResultLabel("¥0.00"), WARNING_COLOR);
            // 下班剩余
            JPanel remainingPanel = createHighlightValuePanel("下班剩余", remainingTimeLabel = createResultLabel("00:00:00"), WARNING_COLOR);

            // 添加到结果面板
            resultPanel.add(Box.createVerticalGlue()); // 顶部填充
            resultPanel.add(todayPanel);
            resultPanel.add(Box.createRigidArea(new Dimension(0, 20))); // 间隔
            resultPanel.add(monthPanel);
            resultPanel.add(Box.createRigidArea(new Dimension(0, 20))); // 间隔
            resultPanel.add(remainingPanel);
            resultPanel.add(Box.createVerticalGlue()); // 底部填充

            mainPanel.add(resultPanel, BorderLayout.CENTER);

            // 底部时间显示
            currentTimeLabel = new JLabel();
            currentTimeLabel.setFont(new Font("微软雅黑", Font.PLAIN, 12));
            currentTimeLabel.setForeground(DARK_COLOR);
            currentTimeLabel.setHorizontalAlignment(JLabel.CENTER);
            currentTimeLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0));

            JPanel timePanel = new JPanel(new BorderLayout());
            timePanel.setBackground(LIGHT_COLOR);
            timePanel.add(currentTimeLabel, BorderLayout.CENTER);

            // 返回按钮
            JButton backButton = new JButton("返回") {
                @Override
                protected void paintComponent(Graphics g) {
                    if (getModel().isPressed()) {
                        g.setColor(PRIMARY_COLOR.darker());
                    } else if (getModel().isRollover()) {
                        g.setColor(PRIMARY_COLOR.brighter());
                    } else {
                        g.setColor(PRIMARY_COLOR);
                    }
                    g.fillRoundRect(0, 0, getWidth(), getHeight(), 10, 10);
                    super.paintComponent(g);
                }

                @Override
                public Dimension getPreferredSize() {
                    return new Dimension(120, 35);
                }
            };

            backButton.setFont(new Font("微软雅黑", Font.PLAIN, 12));
            backButton.setForeground(ACCENT_COLOR);
            backButton.setFocusPainted(false);
            backButton.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15));
            backButton.setContentAreaFilled(false);
            backButton.setOpaque(false);

            backButton.addActionListener(e -> {
                dispose();
                SalaryCalculator calculator = new SalaryCalculator();
                calculator.setBounds(previousBounds);
                calculator.setVisible(true);
            });

            JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
            buttonPanel.setBackground(LIGHT_COLOR);
            buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 5, 0));
            buttonPanel.add(backButton);

            JPanel bottomPanel = new JPanel(new BorderLayout());
            bottomPanel.setBackground(LIGHT_COLOR);
            bottomPanel.add(buttonPanel, BorderLayout.NORTH);
            bottomPanel.add(timePanel, BorderLayout.SOUTH);
            mainPanel.add(bottomPanel, BorderLayout.SOUTH);

            add(mainPanel);
        }

        private JPanel createHighlightValuePanel(String title, JLabel valueLabel, Color color) {
            JPanel panel = new JPanel(new BorderLayout(2, 0)); // 保持间距5
            panel.setBackground(PRIMARY_COLOR); // 高亮背景色
            panel.setBorder(BorderFactory.createCompoundBorder(
                    BorderFactory.createLineBorder(SECONDARY_COLOR, 0, true),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)
            ));

            JLabel titleLabel = new JLabel(title);
            titleLabel.setFont(new Font("微软雅黑", Font.BOLD, 16)); // 加粗加大
            titleLabel.setForeground(WARNING_COLOR);

            valueLabel.setForeground(color);
            valueLabel.setFont(new Font("微软雅黑", Font.BOLD, 16)); // 更大的字体

            panel.add(titleLabel, BorderLayout.WEST);
            panel.add(valueLabel, BorderLayout.EAST);

            return panel;
        }

        private JLabel createResultLabel(String text) {
            JLabel label = new JLabel(text);
            label.setFont(new Font("微软雅黑", Font.BOLD, 20));
            label.setForeground(WARNING_COLOR);
            label.setHorizontalAlignment(JLabel.RIGHT);
            return label;
        }

        private void startTimer() {
            timer = new Timer(100, e -> {
                updateEarnings();
            });
            timer.start();
        }

        private void updateEarnings() {
            LocalDateTime now = LocalDateTime.now();
            LocalDateTime todayStartTime = LocalDateTime.of(today, startTime);
            LocalDateTime todayEndTime = LocalDateTime.of(today, endTime);

            // 如果当前时间早于上班时间，按上班时间计算
            if (now.isBefore(todayStartTime)) {
                now = todayStartTime;
            }

            // 如果当前时间晚于下班时间，按下班时间计算
            if (now.isAfter(todayEndTime)) {
                now = todayEndTime;
            }

            // 计算当天已工作秒数
            long workedSecondsToday = ChronoUnit.SECONDS.between(todayStartTime, now);
            if (workedSecondsToday < 0) workedSecondsToday = 0;

            // 计算当天已赚
            double currentDayEarnings = secondSalary * workedSecondsToday;

            // 计算当月已过天数（包括今天）
            int daysWorkedThisMonth = today.getDayOfMonth();

            // 计算当月已赚
            double monthEarnings = dailySalary * (daysWorkedThisMonth - 1) + currentDayEarnings;

            // 计算下班剩余时间
            long remainingSeconds = ChronoUnit.SECONDS.between(now, todayEndTime);
            if (remainingSeconds < 0) remainingSeconds = 0;

            // 格式化剩余时间为 HH:MM:SS
            String remainingTime = String.format("%02d:%02d:%02d",
                    remainingSeconds / 3600,
                    (remainingSeconds % 3600) / 60,
                    remainingSeconds % 60);

            // 更新显示
            currentDayEarningsLabel.setText(String.format("¥%.3f", currentDayEarnings));
            monthEarningsLabel.setText(String.format("¥%.3f", monthEarnings));
            remainingTimeLabel.setText(remainingTime);
        }

        @Override
        public void dispose() {
            if (timer != null && timer.isRunning()) {
                timer.stop();
            }
            super.dispose();
        }

        // 使窗口可拖动
        private void makeFrameDraggable() {
            addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent e) {
                    initialClick = e.getPoint();
                    getComponentAt(initialClick);
                }
            });

            addMouseMotionListener(new MouseMotionAdapter() {
                @Override
                public void mouseDragged(MouseEvent e) {
                    // 获取当前窗口位置
                    int thisX = getLocation().x;
                    int thisY = getLocation().y;

                    // 计算移动距离
                    int xMoved = e.getX() - initialClick.x;
                    int yMoved = e.getY() - initialClick.y;

                    // 移动窗口
                    setLocation(thisX + xMoved, thisY + yMoved);
                }
            });
        }
    }

    // 自定义阴影面板类
    private static class ShadowPanel extends JPanel {
        private static final int SHADOW_SIZE = 10;

        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2d = (Graphics2D) g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

            // 绘制阴影
            Color shadowColor = new Color(0, 0, 0, 50);
            for (int i = 0; i < SHADOW_SIZE; i++) {
                g2d.setColor(new Color(
                        shadowColor.getRed(),
                        shadowColor.getGreen(),
                        shadowColor.getBlue(),
                        shadowColor.getAlpha() - (i * 5)
                ));
                g2d.drawRoundRect(
                        i, i,
                        getWidth() - i * 2 - 1,
                        getHeight() - i * 2 - 1,
                        10, 10
                );
            }

            // 绘制内容区域
            g2d.setColor(getBackground());
            g2d.fillRoundRect(
                    SHADOW_SIZE, SHADOW_SIZE,
                    getWidth() - SHADOW_SIZE * 2,
                    getHeight() - SHADOW_SIZE * 2,
                    5, 5
            );
        }

        @Override
        public Dimension getPreferredSize() {
            return new Dimension(super.getPreferredSize().width + SHADOW_SIZE * 2,
                    super.getPreferredSize().height + SHADOW_SIZE * 2);
        }
    }

    public static void main(String[] args) {
        // 设置系统外观
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            e.printStackTrace();
        }

        // 设置全局字体
        Font font = new Font("微软雅黑", Font.PLAIN, 14);
        UIManager.put("Label.font", font);
        UIManager.put("TextField.font", font);
        UIManager.put("Button.font", font);
        UIManager.put("ComboBox.font", font);
        UIManager.put("CheckBox.font", font);
        UIManager.put("RadioButton.font", font);
        UIManager.put("Menu.font", font);
        UIManager.put("MenuItem.font", font);
        UIManager.put("OptionPane.messageFont", font);
        UIManager.put("OptionPane.buttonFont", font);

        SwingUtilities.invokeLater(() -> new SalaryCalculator().setVisible(true));
    }
}